import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import storage from '../components/uview-ui/libs/function/storage'
import { TOKEN, USER_INFO } from './mutation-types'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    user
  },
  state: {
  },
  mutations: {
  },
  actions: {
  },
  getters: {
    token: state => { state.user.token = storage.get(TOKEN); return state.user.token },
    avatar: state => { state.user.avatar = storage.get(USER_INFO).avatar; return state.user.avatar },
    username: state => state.user.username,
    userInfo: state => { state.user.info = storage.get(USER_INFO); return state.user.info }
  }
})
